package com.informatics.polymer.client.mltk;

import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.VisibilityMode;
import com.smartgwt.client.widgets.Button;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.SectionStack;
import com.smartgwt.client.widgets.layout.SectionStackSection;

/**
 * Class to build a panel to use machine learning algorithms to cluster and find
 * neighbour repeat units.
 * 
 * @author ed
 * @version 1.0
 */

public class MachineLearningToolKitPanel extends SectionStack {

	public MachineLearningToolKitPanel() {
		setUpPanel();
	}

	private void setUpPanel() {
		this.setVisibilityMode(VisibilityMode.MULTIPLE);
		this.setWidth(1000);
		this.setHeight(500);
		this.setBorder("2px solid #458B00");
		SectionStackSection section1 = new SectionStackSection("MLTK");
		section1.setExpanded(true);
		HTMLFlow welcome = new HTMLFlow();
		welcome.setOverflow(Overflow.AUTO);
		welcome.setPadding(10);
		String welcomeString = "Welcome to the <I>\"Machine Learning  ToolKit\"</I> panel, please see the instructions tab "
				+ "below for more details on how to cluster, and find nearest neighbour repeat units.";
		welcome.setContents(welcomeString);
		section1.addItem(welcome);
		this.addSection(section1);
		this.setStyleName("sectionHeaderclosed");
		this.setBackgroundColor("#F0F0F0");
		// Add K-NN section
		SectionStackSection knnSection = new SectionStackSection("<I>K</I>NN");
		this.addSection(knnSection);
		// Add K-Means cluster section
		SectionStackSection kMeansSection = new SectionStackSection(
				"<I>K</I>Means");
		this.addSection(kMeansSection);
		// Add instructions section.
		SectionStackSection instructionSection = new SectionStackSection(
				"Instructions");
		instructionSection.setExpanded(false);
		HTMLFlow browseRepeatUnitInstructions = new HTMLFlow();
		browseRepeatUnitInstructions.setOverflow(Overflow.AUTO);
		browseRepeatUnitInstructions.setPadding(10);
		String instructions = "1. <b>Using the MLTK</b><br></br> You can cluster repeat unit structures and find nearest neighbours.<br></br>"
				+ "2. <b>Delete Panel</b><br></br> If you are not happy with your selection or choose to view another panel you can click on the <I>\"Delete Panel\"</I> and press the delete panel button"
				+ " this will delete the browse repository panel, so you can start over again.<br></br>";
		browseRepeatUnitInstructions.setContents(instructions);
		instructionSection.addItem(browseRepeatUnitInstructions);
		this.addSection(instructionSection);
		// Delete panel section
		SectionStackSection deletePanelSection = new SectionStackSection(
				"Delete Panel");
		deletePanelSection.setExpanded(false);
		Button deletePanelButton = new Button("Delete Panel!");
		deletePanelButton.setSize("100", "30");
		deletePanelButton.addClickHandler(new ClickHandler() {
			@Override
			public void onClick(ClickEvent event) {
				destroy();
			}
		});
		deletePanelSection.addItem(deletePanelButton);
		this.addSection(deletePanelSection);

	}
}
